<template>
	<div>
		<Search :proList="proList" />
		<List v-if="courseArr.length" :courseArr="courseArr" :proList="proList" />
		<Add v-if="courseArr.length" :courseArr="courseArr" />
	</div>
</template>
<script>
// import { tbDictDefinitionQueryEnumList } from '@/api/admin/system/dictionary'
export default {
	components: {
		Search: () => import('./components/Search.vue'),
		List: () => import('./components/List.vue'),
		Add: () => import('./components/Add.vue')
	},
	data() {
		return {
			courseArr: [],
			listQuery: {
				page: 1,
				limit: 99,
				type: 1,
				code: 'pxzy'
			},
			proList: [
				['777', '778', '779'],
				['91', '93', '92']
			]
		};
	},
	mounted() {
		this.queryType();
	},
	methods: {
		getIndexByValue(arr, value) {
			for (var i = 0; i < arr.length; i++) {
				if (arr[i].code === value) {
					return i;
				}
			}
			return -1; // 如果找不到匹配的值，则返回 -1
		},
		//查询分类类型
		async queryType() {
			let res = await this.$store.dispatch('querySysColumnControl', this.listQuery);
			if (!res.data.length) return;
			this.courseArr = [];
			let arr = [
				// { value: '1', code: 'kck' },
				// { value: '2', code: 'zyk' },
				// { value: '3', code: 'bzk' },
				// { value: '4', code: 'ztk' },
				// { value: '5', code: 'sfwsp' },
				{ value: '6', code: 'pxzy' }
			];
			res.data.filter((item) => {
				let idx = this.getIndexByValue(arr, item.code);
				if (idx != -1) {
					this.courseArr.push({ value: arr[idx].value, msg: item.name });
				}
			});
		}
	}
};
</script>
